import 'package:flutter_ncsjqz_getx/http/dio_service.dart';
import 'package:flutter_ncsjqz_getx/model/base_entity.dart';
import 'package:flutter_ncsjqz_getx/model/my_follow_entity.dart';
import 'package:get/get.dart';

class FansFollowLogic extends GetxController {

  int? followType;// 1关注 2粉丝
  List<MyFollowDataList>? xList = [];

  getData() async{
    Map<String,dynamic> map = {
      "pageSize":10,
      "currPage":0,
      "followType": followType,
    };
    MyFollowEntity myFollowEntity = await DioService<MyFollowEntity>().followAndFansPage(map);
    xList = myFollowEntity.data!.xList;
    update();
  }

  setFollow(followUserId,index) async{
    BaseEntity baseEntity = await DioService<BaseEntity>().clickFollow({
      "beFollowUserId": followUserId,
    });
    if(baseEntity.code == 0){
      xList![index].isAttention = !xList![index].isAttention!;
      update();
    }
  }

  canFollw(beFollowUserId,index) async{
    BaseEntity baseEntity = await DioService<BaseEntity>().cancelFollow({
      "beFollowUserId": beFollowUserId,
    });
    if(baseEntity.code == 0){
       getData();
    }
  }
}
